<template>
  <DataList :signle="true" :single="true" :cate="cate" :cols="cols" :name="name" />
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import { addZxxsdqhjmzqk, deleteZxxsdqhjmzqk, updateZxxsdqhjmzqk, getZxxsdqhjmzqk } from "@/api/在校学生的地区户口所在地及民族等情况.js";
export default {
  components: {
    DataList
  },
  data() {
    return {
      cate: "A11-2在校学生的地区、户口所在地及民族等情况",
      name:'11.2 在校学生的地区、户口所在地及民族等情况',
      cols: [
        { label: "在校生总数(人)", prop: "ZXSZS" },
        { label: "其中", prop: "其中" ,data:[
            {label:'外省学生数(人)',prop:'WSXSS'},
            { label: "比例(%)", prop: "WSXSS_BL" },
            { label: "西部地区学生数(人)", prop: "XBDQXSS" },
            {label:'比例(%)',prop:'XBDQXSS_BL'},
            { label: "常住户口所在地为农村的学生数(人)174", prop: "NCHJXSS" },
            { label: "比例(%)", prop: "NCHJXSS_BL" },
            {label:'贫困地区175学生数(人)',prop:'PKDQXSS'},
            { label: "比例(%)", prop: "PKDQXSS_BL" },
            { label: "少数民族学生数(人)", prop: "SSMZXSS" },
            { label: "比例(%)", prop: "SSMZXSS_BL" }
        ]},
        { label: "国际学生数(人)176", prop: "GJXSS" },
        { label: "境外学生数(人)", prop: "JWXSS" }
      ]
    };
  },
  methods: {
    check(array,list) {
       return new Promise(async (resolve,reject)=>{
         try{
          linq
            .from(array)
            .where(e => err.indexOf(e.BMMC+','+e.ZYDM + "," + e.ZYFXDM) !== -1)
            .forEach(
              e =>
                (e.error = e.error
                  ? e.error + ";"
                  : "" + "数据库中已经存在相同的系部名称,专业方向代码与专业代码组合")
            );
            resolve();
          }catch(e){
            reject(e);
          }
     }) 
    },
    async onChange(model, field, value){
      model.WSXSS_BL   =   ((model.WSXSS / model.ZXSZS).toFixed(2))*100
      model.XBDQXSS_BL = ((model.XBDQXSS / model.ZXSZS).toFixed(2))*100
      model.NCHJXSS_BL = ((model.NCHJXSS / model.ZXSZS).toFixed(2))*100
      model.PKDQXSS_BL = ((model.PKDQXSS/ model.ZXSZS).toFixed(2))*100
      model.SSMZXSS_BL = ((model.SSMZXSS / model.ZXSZS).toFixed(2))*100
    },
    onadd(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
      
          console.log(JSON.stringify(temp));
          var model = await addZxxsdqhjmzqk(temp);
          resolve(model);
      })
      
    },
    onupdate(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
          console.log(JSON.stringify(temp));
          var model = await updateZxxsdqhjmzqk(temp);
          resolve(model);
      })
      //
    },
    ondelete(model) {
       var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
        
         await deleteZxxsdqhjmzqk(temp);
          resolve();
      })
    },
    async fetchData() {
      var user = getUser();
      var datas = await getZxxsdqhjmzqk(user.XXID,user.CJPC);
      return datas;
    }
  }
};
</script>
<style>
</style>